use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("QUIC error: {0}")]
    Quinn(#[from] quinn::ConnectionError),

    #[error("H3 error: {0}")]
    H3(#[from] h3::Error),

    #[error("Invalid packet")]
    InvalidPacket,

    #[error("Invalid request ID")]
    InvalidRequestId,

    #[error("Varint overflow")]
    VarintOverflow,

    #[error("Incomplete varint")]
    IncompleteVarint,

    #[error("Missing auth header")]
    MissingAuthHeader,

    #[error("UTF-8 error: {0}")]
    Utf8(#[from] std::string::FromUtf8Error),

    #[error("Authentication failed")]
    AuthenticationFailed,

    #[error("Connection closed")]
    ConnectionClosed,

    #[error("Other error: {0}")]
    Other(String),
}

pub type Result<T> = std::result::Result<T, Error>;
